package com.acoreful.acf2admin.commons.utils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class PemFileUtils {

	public static String read(String pemFilePath) {
		InputStream is=ClassLoader.getSystemResourceAsStream(pemFilePath);
		BufferedReader br =null;
		try {
			br = new BufferedReader(new InputStreamReader(is));
			String s = br.readLine();
			StringBuffer publickey = new StringBuffer();
			s = br.readLine();
			while (s.charAt(0) != '-') {
			    publickey.append(s + "\r");
			    s = br.readLine();
			}
			return publickey.toString();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			if(br!=null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		return null;
	}
}
